<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/29 0029
 * Time: 下午 5:34
 */
namespace app\wx\controller;
use think\Controller;
use think\Db;
use think\Request;
use think\Validate;
use app\wx\controller\Home;

class Apply extends Home
{
    //我要申请
    public function apply(){
        $this->is_login();
        $this->view->manages = Db::name('core_form_manage')->select();
        return $this->fetch();
    }

    //填写申请表单
    public function applying(){
//        $this->is_login();
        if($this->request->isPost()) {
            $data = input('post.');
            $data['register_id'] = session('user_id');
            $data['apply_id'] = $data['classify_id'];
            $data['create_time'] = time();
            $data['order_num'] = date('Ymd').rand(10000000,99999999);
            unset($data['classify_id']);
            unset($data['radio1']);
            Db::name('core_table'.$data['pid'])->insert($data);
            return json(200);
        }
        $this->view->name_manages = Db::name('core_form_name_manage')->where(['pid'=>input('id'),'delete_id'=>2])->select();
        $this->view->manage = Db::name('core_form_manage')->where('id',input('id'))->find();//押金那用
        $this->view->tablename = Db::name('core_form_manage')->where('id',input('id'))->value('table_name');
        $register_ids = Db::name('core_form_manage')->where('id',input('id'))->value('register_ids');
        $this->view->register = Db::name('core_register')->where('id','in',$register_ids)->select();//获得下拉列表
        $this->view->pid = input('id');
        return $this->fetch();
    }
}